﻿' LibWowArmory
' by Ronald M. Clifford (roncli@roncli.com)
'
' This source code is released under the GNU Library General Public License (LGPL) Version 2.1.

Imports System
Imports System.Collections.Specialized
Imports System.Web

Namespace roncliProductions.LibWowArmory

    ''' <summary>
    ''' A helper class to create a URI with a query string
    ''' </summary>
    ''' <remarks></remarks>
    Public Class URIQueryStringCollection
        Inherits NameValueCollection

        Private Property BaseURI As Uri

        ''' <summary>
        ''' Creates a new URI Builder object with a base URI
        ''' </summary>
        ''' <param name="uBaseURI"></param>
        ''' <remarks></remarks>
        Public Sub New(ByVal uBaseURI As Uri)
            BaseURI = uBaseURI
        End Sub

        ''' <summary>
        ''' Returns the URI complete with the querystring
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function ToURI() As Uri
            Dim ubURI As New UriBuilder(BaseURI)
            Dim hvcCollection = HttpUtility.ParseQueryString(String.Empty)

            For Each strKey As String In MyBase.Keys
                hvcCollection(strKey) = MyBase.Item(strKey)
            Next

            ubURI.Query = hvcCollection.ToString()
            Return ubURI.Uri
        End Function

    End Class

End Namespace
